<?php
class XExecutionPointcut extends XAbstractPointcut{
	public function match($class, $method){
		$match = array();
		if(!preg_match("/^execution\(([\w*]+)\s+([\w*]+)\.([\w*]+)\(\)\)/i", $this->pattern, $match)){
			return false;	
		}
		$function = XClassLoader::loader($class)->reflection()->getMethod($method);
		if(is_null($function)){
			return false;
		}
		$modifier = '';
		if($function->isPublic()){
			$modifier = 'public';
		}elseif($function->isPrivate()){
			$modifier = 'private';
		}elseif($function->isProtected()){
			$modifier = 'protected';
		}
		if($match[1]!='*'
			&& strtolower($match[1])!=$modifier){
			return false;
		}
		$classPattern = str_replace("*", "(.+)", $match[2]);
		if(!preg_match("/{$classPattern}/i", $class)){
			return false;
		}
		$methodPattern = str_replace("*", ".+", $match[3]);
		if(!preg_match("/{$methodPattern}/i", $method)){
			return false;
		}
		return true;
	}
}
?>